package com.sc.nft.entity;

import java.io.Serializable;

import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.annotation.TableName;
import com.sc.nft.sup.SuperEntity;

import java.math.BigDecimal;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.commons.lang.StringUtils;

/**
 * IP商城商品规格表(sc_mall_product_specs)实体类
 *
 * @author zxy
 * @description IP商城
 * @since 2023-05-10 16:59:01
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("sc_mall_product_specs")
public class MallProductSpecs extends SuperEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 商品Id
     */
    private Long productId;

    /**
     * API商品Id
     */
    private Integer apiProductId;

    /**
     * API商品模板Id
     */
    private String apiProductTemplateId;

    /**
     * API商品包括元素
     */
    private String apiProductElementInfo;

    /**
     * API商品游戏区服模板信息
     */
    private String apiGameTemplatePreviewList;

    /**
     * 渠道库存Id
     */
    private Long inventoryId;
    /**
     * 缩略图
     */
    private String thumbnail;
    /**
     * 规格名称
     */
    private String specsName;
    /**
     * 规格编码
     */
    private String specsCode;
    /**
     * 成本价
     */
    private BigDecimal costPrice;

    /**
     * 发货编码
     */
    private String sendCode;

    /**
     * 添加规格
     */
    public static MallProductSpecs build(Long productId, String thumbnail, String specsName, BigDecimal costPrice, Integer apiProductId,
                                         String apiProductTemplateId, String apiProductElementInfo, String apiGameTemplatePreviewList) {
        MallProductSpecs mallProductSpecs = new MallProductSpecs();
        mallProductSpecs.productId = productId;
        mallProductSpecs.specsName = specsName;
        if (StringUtils.isBlank(thumbnail)) {
            thumbnail = "";
        }
        mallProductSpecs.thumbnail = thumbnail;
        mallProductSpecs.costPrice = costPrice;
        mallProductSpecs.specsCode = IdUtil.getSnowflakeNextIdStr();
        mallProductSpecs.apiProductId = apiProductId;
        mallProductSpecs.apiProductTemplateId = apiProductTemplateId;
        mallProductSpecs.apiProductElementInfo = apiProductElementInfo;
        mallProductSpecs.apiGameTemplatePreviewList = apiGameTemplatePreviewList;
        return mallProductSpecs;
    }

}